package com.csair.seam.infrastructure.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class BaseInterceptor {
	/*返回客户端数据*/
	@SuppressWarnings("all")
    protected void returnJson(HttpServletResponse response,
                            String json){
        PrintWriter writer = null;
        response.setCharacterEncoding("UTF-8");
        response.setContentType(MediaType.APPLICATION_JSON_UTF8.toString());
        try {
            writer = response.getWriter();
            writer.print(json);
        } catch (IOException e) {
            log.error("Interceptor response error",e);
        } finally {
            if (writer != null)
                writer.close();
        }
    }
    
}
